/**
 * 
 */
package leetCode;

/**
 * @author zhong
 *
 */
public class MonotonicArray {
	public boolean isMonotonic(int[] A) {
		boolean larger = false;
		boolean less = false;
		for (int i = 1; i < A.length; i++) {
			if (A[i - 1] < A[i]) {
				less = true;
			} else if (A[i - 1] > A[i]) {
				larger = true;
			}
		}
		return !(larger && less);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] A = { 1, 2, 2, 3 };
		System.out.println(new MonotonicArray().isMonotonic(A));
	}

}
